<template>
  <div class="app-container">
      <div>
          教师工号：{{teach.teachAccount}}
          教师姓名：{{teach.teachName}}
          教师手机号码：{{teach.teachPhone}}
      </div>
      <el-divider></el-divider>
      <div>
        <el-table :data="studentList" style="width: 100%;margin-top:30px;" border>
            <el-table-column align="center" label="学号" width="200">
                <template slot-scope="scope">
                {{ scope.row.studentAccount }}
                </template>
            </el-table-column>
            <el-table-column align="center" label="姓名" width="220">
                <template slot-scope="scope">
                {{ scope.row.studentName }}
                </template>
            </el-table-column>
            <el-table-column align="header-center" label="班级">
                <template slot-scope="scope">
                {{ scope.row.class }}
                </template>
            </el-table-column>
            <el-table-column align="center" label="操作">
                <template slot-scope="scope">
                <el-button type="primary" size="small" @click="handleAssignRole(scope)">查看报告</el-button>
                </template>
            </el-table-column>
         </el-table>
          <!--分页组件-->
            <el-pagination background layout="prev, pager, next"  prev-text="上一页"
            next-text="下一页"
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page.sync="currpage"
            :page-size="pageSize"
            :total="total">
            </el-pagination>
      </div>
  </div>

</template>

<script>
import {getStudent} from '@/api/tutor'
import {getTeachDetail} from '@/api/teach'

export default {
  data() {
    return {
      param :{
      start: 0,
      limit: 10,
      teachAccount:''
      },
      total:'',
      studentList:[],
      pageSize:10,
      currpage: 1, //当前页
      teach:{
        teachAccount:'',
        teachName:'',
        teachPhone:''
      }
    }
  },
  //页面打开时执行的方法
  created() {
    this.param.teachAccount = this.$route.query.teachAccount;
    this.getStudent()
    this.getTeachDetail()
  },
  methods: {
    async getStudent() {
      let res = await getStudent(this.param)
      this.studentList = res.beans
      this.total = res.bean.total
    },
    async getTeachDetail() {
      let res = await getTeachDetail(this.param)
      this.teach = res.bean
    },
    //页大小变化
     handleSizeChange(val) {
      this.pageSize = val;
      this.param.start = this.pageSize*(this.currpage-1)
      this.getTeachList();
    },
    //页标号变化
    handleCurrentChange(val) {
      this.currpage = val;
      this.param.start = this.pageSize*(this.currpage-1)
      this.getUserList();
    },
  }
}
</script>

<style lang="scss" scoped>

</style>
